home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
101-125
/
scopedisk120
/
mrcat
/
readme
< prev
next >
Wrap
Text File
|
1995-03-19
|
3KB
|
78 lines
This posting contains the following:
- FileScan.c/h: stdio-based filename list expansion/sort package
- ArpFileScan.c/h: ARP-based filename list expansion/sort package
- MRCat: A "cat" program which uses ArpFileScan or FileScan
This is another one of those "Anybody could have written it so why don't I
have one?" packages. It was trivial to write but useful enough to share.
I've recently shifted my Usenet source/binary archive activities from the
UnixPC at work to my Amiga. As you're aware, many of these postings
consist of groups of similarly named files which, when catenated and
uudecoded, produce (most times) something useful - usually a Zoo archive
full of goodies. Some of these postings come in many parts which have to
be joined in a specific sequence. If you're using a shell which expands
wildcard file specifications and sorts the expanded list, more power to
ya'! I don't. I thought it might be nice to have a "cat" which would do
this for me. I further realized that I frequently port Unix code which
needs to do this sort of thing. How about a package to expand/sort
filename lists which is easy to incorporate into foreign code?
I've provided a "standard I/O" version, called FileScan, which uses the
Aztec scdir() function as its file scanner. Since I do a lot of ARP-based
stuff, I then cooked up ArpFileScan which uses FindFirst()/FindNext() to
accomplish the same thing. The ARP version is fully reentrant. The stdio
version would be reentrant if scdir() was.
You pass each of these a pointer to a list of strings (char *[] or char **,
usually the tail end of your program parameter list), a string count, the
address of an integer (new count) and a boolean which specifies if you want
the list sorted. You get back an expanded filename list (char ** again)
and the new file name count. In both versions, the list is allocated from
tracked memory which will be freed when the program exits. Example:
main(int argc, char **argv)
{
int argn = 1;
char **fileList;
int fileCount;
int fileIndex;
char *theFile;
...process "-" options, incrementing argn along the way...
fileList = FileScan(&argv[argn], argc-argn, &fileCount, 1);
if (fileList)
for (fileIndex = 0; fileIndex < fileCount; ++fileIndex) {
theFile = fileList[fileIndex];
...do stuff to/with theFile...
}
...
MRCat will catenate any file(s) or standard input to standard output. It
treats each filename parameter as a group of 1 or more filenames. The
order of the basic parameters is not changed, so
MRCat c b a
will copy the files in c, b, a order. However,
MRCat c* b* a
Will copy c1..cn in sorted order, then b1..bn, then a.
I chose a buffer size of 32K for MRCat. This should minimize thrashing
while keeping memory requirements reasonable. This is contributed to the
public domain. You are free to do anything with the enclosed code - just
don't hurt yourself :-).
Mark Rinfret, 03/11/90